import request from '@/utils/request.js'
// 获取频道的文章列表
export const getArticles = params => {
  return request({
    method: 'GET',
    url: '/v1_0/articles',
    params,
  })
}
// 获取文章详情
export const getArticleById = id => {
  return request({
    url: `/v1_0/articles/${id}`,
    method: 'Get',
  })
}
// 收藏文章
export const addCollect = target => {
  return request({
    url: '/v1_0/article/collections',
    method: 'POST',
    data: {
      target,
    },
  })
}
// 取消收藏
export const deleteCollect = target => {
  return request({
    url: `/v1_0/article/collections/${target}`,
    method: 'DELETE',
  })
}
// 点赞
export const addLike = articleId => {
  return request({
    url: '/v1_0/article/likings',
    method: 'POST',
    data: {
      target: articleId,
    },
  })
}
// 取消点赞
export const deleteLike = articleId => {
  return request({
    url: `/v1_0/article/likings/${articleId}`,
    method: 'DELETE',
  })
}
